/**
 * Creates Handlers for UI and IO. 
 * Acts as centralised start and end point for program.
 * @author jon
 */

package manager;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import ui.AgentCreationScreen;
import ui.IdleScreen;

import java.util.Vector;


public class AgentManagerMIDlet extends MIDlet{
	private Display display;
	private UIHandlerManager uiHandler;
	private IOHandlerManager ioHandler;
	
		public AgentManagerMIDlet(){
			display = Display.getDisplay(this);
		}
		
		/*Called upon instanciation */
		public void startApp(){
			try{
				uiHandler = new UIHandlerManager(this,display);
				uiHandler.run();
			}catch(Exception e){
				e.printStackTrace();
			}
	    }
		
		public void createIOHandlerManager(String address){
			String appID = getAppProperty("MMS-ApplicationID");
			this.ioHandler = new IOHandlerManager(this,address, appID);
			this.ioHandler.run();
		}
		
		public IOHandlerManager getIOHandlerManager(){
			return this.ioHandler;
		}
		
		public UIHandlerManager getUIHandlerManager(){
			return this.uiHandler;
		}
		
		/* On pause */
	    public void pauseApp(){}

	    /*On destruction */
	    public void destroyApp(boolean b){}


	    // A convenience method for exiting
	    public void exitRequested(){
	        destroyApp(false);
	        notifyDestroyed();
	    }
}